﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{

    class Program
    {
        enum role
        { 刘备 = 1, 孙权, 曹操 }


        static void Main(string[] args)
        {

            Rule();
        }

        private static void Rule() 
        {
            Computer comparer = new Computer();  
            Judgment j = new Judgment();
            Person p = new Person();
            Console.WriteLine("***************欢迎来到游戏世界***************");
            Console.WriteLine();
            Console.WriteLine("***************猜拳游戏***************");
            Console.WriteLine();
            Console.WriteLine("请选择对方的角色：");
            Console.WriteLine("1、刘备     2、孙权        3、曹操");
            role key = (role)(int.Parse(Console.ReadLine()));
            Console.WriteLine("请输入你的姓名");
            j.PerName = Console.ReadLine();
            switch (key)
            {
                case role.刘备:
                    j.ComputerName = "刘备";                   
                    Console.WriteLine("{0} VS {1}",j.PerName , role.刘备);
                    break;
                case role.孙权:
                    j.ComputerName = "孙权";
                    Console.WriteLine("{0} VS {1}", j.PerName, role.孙权);
                    break;
                case role.曹操:
                    j.ComputerName = "曹操";
                    Console.WriteLine("{0} VS {1}", j.PerName, role.曹操);
                    break;
                default:
                    break;
            }
                sa(j,p,comparer );
        
        }
        public static void sa(Judgment j ,Person p, Computer comparer) 
        {
            int sum = 1;
            int a = 0;
            int b = 0;
            j.PerNum = p.State();
            j.ComNum = comparer.sj();
            j.ju();
            Console.WriteLine("是否继续 y/n");
            if (Console.ReadLine().Equals("y"))
            {
                sum++;
                j.PerNum = p.State();
                j.ComNum = comparer.sj();
                j.ju();
                if (j.PerNum > j.ComNum)
                {
                   
                    a++;
                   
                }
                else if (j.PerNum < j.ComNum)
                {
                    b++;
                }
                else
                {

                }
                sa(j, p, comparer);
            }
            else
            {
                Console.WriteLine("{0}   VS  {1}", j.PerName, j.ComputerName);
                Console.WriteLine("对战次数：{0}", sum);
                Console.WriteLine();
                Console.WriteLine("姓名       得分");
                Console.WriteLine("{0}      {1}", j.PerName, a);
                Console.WriteLine("{0}      {1}", j.ComputerName, b);
                if (a > b)
                {
                    Console.WriteLine("结果：{0} 赢了", j.PerName);


                }
                else
                {
                    Console.WriteLine("结果：{0} 赢了", j.ComputerName);
                }
            }
        }

    }
}
